import {reqcatelist,reqcateinfo} from "../../request/api.js"

const state={
    info:{
        isshow:false,
        isadd:true
    },
    catelist:[],
    cateinfo:[],
}
const getters={
    info(state){
        return state.info
    },
    catelist(state){
        return state.catelist
    },
    cateinfo(state){
        return state.cateinfo
    },
}
const mutations={
    changeinfo(state,data){
        state.info=data
    },
    catelist(state,data){
        state.catelist=data
    },
    cateinfo(state,data){
        state.cateinfo=data
    },
}
const actions={
    catelist(context){
        reqcatelist({istree:true}).then(res=>{
            context.commit("catelist",res.data.list)
            console.log(res);
            
        })
    },
    cateinfo(context,data){
        reqcateinfo(data).then(res=>{
            res.data.list.id=data.id
            context.commit("cateinfo",res.data.list)
        })
    },

}
export default{
    state,
    getters,
    mutations,
    actions,
    namespaced:true
}